<template>
    <div>
        <h3 style="color: red">
            读取state中存储的变量count
            {{$store.state.count}}
            <br>
            Getters (自定义的get方法)可以用于监听、state中的值的变化，返回计算后的结果
            {{$store.getters.getStateCount}}

        </h3>

        <button @click="handleActionsAdd(10)">异步增加</button>
        <button @click="handleActionsReduce(10)">异步减少</button>

    </div>
</template>

<script>
    export default {
        name: "DemoVuex",
        data () {
            return {

            }
        },
        methods:{
            handleActionsAdd(n){
                this.$store.dispatch('actionsAddCount',n)
            },
            handleActionsReduce(n){
                this.$store.dispatch('actionsReduceCount',n)
            },
        }
    }
</script>

<style scoped>

</style>
